package com.itboye.ihomebank.util;

import android.app.Activity;
import android.util.Log;

import com.itboye.ihomebank.bean.PersonDataBean;
import com.itboye.ihomebank.constants.SPContants;

/**
 * Created by admin on 2016/12/14.
 */

public class SavePersonData {
    public static void saveData(Activity activity, PersonDataBean bean){
        Log.i("result", bean.toString());

        SPUtils.put(activity, null,
                SPContants.USERNAME, bean.getUsername());
        SPUtils.put(activity, null,
                SPContants.MOBILE, bean.getMobile());
        SPUtils.put(activity,null,SPContants.Birthday,bean.getBirthday());
        SPUtils.put(activity,null,SPContants.EMAIL,bean.getEmail());
        SPUtils.put(activity,null,SPContants.QQ,bean.getQq());
        SPUtils.put(activity,null,SPContants.SIGN,bean.getSign());
        if (bean.getMobile() != null) {
            if (bean.getMobile().equals("")) {
                SPUtils.put(activity, null,
                        SPContants.IS_BIND_PHONE, false);
            } else {
                SPUtils.put(activity, null,
                        SPContants.IS_BIND_PHONE, true);
            }
        } else {
            SPUtils.put(activity, null,
                    SPContants.IS_BIND_PHONE, false);
        }
        SPUtils.put(activity, null,
                SPContants.IS_LOGINED, true);
        SPUtils.put(activity, null, SPContants.EMAIL,
                bean.getEmail());
        SPUtils.put(activity, null, SPContants.NICK,
                bean.getNickname());

        if (bean.getPassword() != null) {
            SPUtils.put(activity, null,
                    SPContants.PASSWORD, bean.getPassword());
        }
        SPUtils.put(activity, null,
                SPContants.USER_ID, bean.getId());
        SaveKeyBean.saveData("2",null);
        SPUtils.put(activity, null,
                SPContants.AVATAR_URL, bean.getHead());
        SPUtils.put(activity, null, SPContants.SEX,
                bean.getSex());// 性别
        SPUtils.put(activity, null,
                SPContants.IdentityValidate,// '实名身份认证【0未认证,1已认证,2待审核】'
                bean.getIdentityValidate());
        SPUtils.put(activity, null,
                SPContants.BrokerValidate,
                bean.getBrokerValidate());// 经纪人认证【0未认证,1已认证,2待审核】
        SPUtils.put(activity, null,
                SPContants.ScienerUsername,// 绑定科技侠账号，科技侠账号,为空未绑定
                bean.getScienerUsername());
        SPUtils.put(activity, null,
                SPContants.IdNumBer,// 身份证号码
                bean.getIdnumber());
        if(bean.getWalletPassword()!=null){
            SPUtils.put(activity, null,
                    SPContants.WalletPass,//钱包支付密码
                    bean.getWalletPassword());
        }
        SPUtils.put(activity, null, SPContants.HUANKUAN,
                "1");
        SPUtils.put(activity, null,
                SPContants.RealName, bean.getRealname());// 身份证号码
        SPUtils.put(activity, null, SPContants.BaichuanUID,
                bean.getBaichuanUid());// 阿里百川即时通讯 的uid

        if (bean.getWalletPassword() != null) {// 支付密码
            if (bean.getWalletPassword().equals("")) {
                SPUtils.put(activity, null,
                        SPContants.IS_ZHIFU_PASS, false);
            } else {
                SPUtils.put(activity, null,
                        SPContants.IS_ZHIFU_PASS, true);
            }
        }
//        else {
//            SPUtils.put(activity, null,
//                    SPContants.IS_ZHIFU_PASS, false);
//        }
    }
}
